import request from './request'

// 获取所有激活的分类
export function getActiveCategories() {
  return request({
    url: '/categories',
    method: 'get'
  })
}

// 获取前N个分类
export function getTopCategories() {
  return request({
    url: '/categories/top',
    method: 'get'
  })
}

// 根据ID获取分类
export function getCategoryById(id: number) {
  return request({
    url: `/categories/${id}`,
    method: 'get'
  })
}

// 创建分类
export const createCategory = (data: any) => {
  return request({
    url: '/categories',
    method: 'post',
    data
  })
}

// 更新分类
export const updateCategory = (id: number, data: any) => {
  return request({
    url: `/categories/${id}`,
    method: 'put',
    data
  })
}

// 删除分类
export const deleteCategory = (id: number) => {
  return request({
    url: `/categories/${id}`,
    method: 'delete'
  })
} 